package com.weetop.cfw.utils

import android.content.Context
import android.graphics.drawable.Drawable
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.coorchice.library.ImageEngine
import com.coorchice.library.image_engine.Engine
import com.weetop.cfw.R

class GlideEngine(private var context:Context):Engine {
    override fun load(url: String?, callback: ImageEngine.Callback?) {
        Glide.with(context).load(url).placeholder(R.drawable.cover).error(R.drawable.cover).into(object:SimpleTarget<Drawable>(){
            override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
                // 主要是通过callback返回Drawable对象给SuperTextView
                callback?.onCompleted(resource)
            }

        })
    }
}